#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution
{
public:
    /**
     * @brief -107 <= num <= 107
     * 
     * @param num 
     * @return string 
     */
    string convertToBase7(int num)
    {
        if (0 == num)
        {
            return "0";
        }
        string ans = "";
        bool isNegative = false;
        if (num < 0)
        {
            num = -num;
            isNegative = true;
        }

        while (num)
        {
            ans += to_string(num % 7);
            num /= 7;
        }
        reverse(ans.begin(), ans.end());
        return isNegative ? ("-" + ans) : ans;
    }
};
int main()
{
    Solution s;
    cout << s.convertToBase7(0) << endl;
    return 0;
}
